<?php
  $link = mysql_connect('', 'admin_xbq', 'nihao')
      or die('Could not connect: ' . mysql_error());
  echo "Connected successfully\n";
  echo '<br /><br />';

  $query = "use test";
  $result = mysql_query($query) or die('Query failed1: ' . mysql_error());

  //here you can't change ID.
  $sql = 'update user set sr_ID=\''.$_POST['s_id'].
  '\', login=\''.$_POST['login'].
  '\', password=\''.$_POST['password'].
  '\', user_type=\''.$_POST['type'].
  '\', user_name=\''.$_POST['user_name'].
  '\', user_duty=\''.$_POST['duty'].
  '\', phone=\''.$_POST['phone'].
  '\', email=\''.$_POST['email'].
  '\' where user.user_ID='.$_GET['user_id'].';';
  mysql_query($sql) or die('Query failed2: ' . mysql_error());

  $sql = "select * from user where user.user_ID=".$_GET['user_id'];
  $result = mysql_query($sql) or die('Query failed3: ' . mysql_error());

  $line = mysql_fetch_array($result, MYSQL_ASSOC);
  mysql_close($link);
?>

<div  align="center">
  <table align="center" width="400">
    <tr>
      <td class="style3">User ID:</td>
      <td align="right" class="style3">
        <?php echo $line['user_ID'];?>
      </td>
    </tr>
    <tr>
      <td class="style3">Staff room ID:</td>
      <td align="right" class="style3">
        <?php echo $line['sr_ID'];?>
      </td>
    </tr>
    <tr>
      <td class="style3">User name:</td>
      <td align="right" class="style3">
        <?php echo $line['user_name'];?>
      </td>
    </tr>
    <tr>
      <td class="style3">Login:</td>
      <td align="right" class="style3">
        <?php echo $line['login'];?>
      </td>
    </tr>
    <tr>
      <td class="style3">Password:</td>
      <td align="right" class="style3">
        <?php echo $line['password'];?>
      </td>
    </tr>
    <tr>
      <td class="style3">User type:</td>
      <td align="right" class="style3">        
        <?php echo $line['user_type'];?>
      </td>
    </tr>
    <tr>
      <td class="style3">User duty:</td>
      <td align="right" class="style3">
        <?php echo $line['user_duty'];?>
      </td>
    </tr>
    <tr>
      <td class="style3">User phone:</td>
      <td align="right" class="style3">
        <?php echo $line['phone'];?>
      </td>
    </tr>
    <tr>
      <td class="style3">User e-mail:</td>
      <td align="right" class="style3">
        <?php echo $line['email'];?>
      </td>
    </tr>
    <tr>
      <td class="style3" align="left">
        <a href="edit_teacher.php?user_id=<?php echo $_GET['user_id'];?>">
          Edit
        </a>
      </td>
      <td align="right" class="style3">
        <a href="show_teacher.php?sr_id=<?php echo $line['sr_ID'];?>">
          Done
        </a>
      </td>
    </tr>
  </table>
</div>
